

find_path(FFMPEG_INCLUDE_DIR libavutil/avutil.h
		${THIRD_PARTY}/ffmpeg/include
		${PROJECT_ROOT}/third_party/ffmpeg/include
		${UNIMEDIACORE_ROOT_DIR}/third_party/ffmpeg/include
		)



if (FFMPEG_INCLUDE_DIR)
	get_filename_component(FFMPEG_DIR ${FFMPEG_INCLUDE_DIR} PATH)
	set(FFMPEG_ROOT_DIR ${FFMPEG_DIR})
	set(FFMPEG_LIB_DIR ${FFMPEG_DIR}/lib)
	set(FFMPEG_FOUND TRUE)
		
	if (WIN32)
		SET(FFMPEG_LIBRARIES avutil avcodec avformat swresample avfilter swscale)
		SET(FFMPEG_AVUTIL avutil avcodec)
		
		SET(FFMPEG_LIBRARY_DIR ${FFMPEG_DIR}/bin)
		
	else (WIN32)

		SET(FFMPEG_LIBRARIES avutil-56 avcodec-58 avformat-58 swresample-3 avfilter-7 swscale-5)
		SET(FFMPEG_AVUTIL avutil-56 avcodec-58)
		
		SET(FFMPEG_LIBRARY_DIR ${FFMPEG_DIR}/lib)
		
	endif (WIN32)

	#message("FFMPEG_LIBRARY_DIR: ${FFMPEG_LIBRARY_DIR}")
	
	if (WIN32)
		if(CMAKE_CL_64)
			SET(FFMPEG_LIBRARY_DIR ${FFMPEG_ROOT_DIR}/x64)
		endif()
	else(WIN32)
		
		if(CMAKE_TOOLCHAIN_FILE)
			
			if (CMAKE_C_COMPILER MATCHES "hisiv300")
				SET(FFMPEG_LIBRARY_DIR ${FFMPEG_DIR}/hisiv300)
			endif()
		
			if (CMAKE_C_COMPILER MATCHES "hisiv400")
				SET(FFMPEG_LIBRARY_DIR ${FFMPEG_DIR}/hisiv400)
			endif()
		
			if (CMAKE_C_COMPILER MATCHES "hisiv500")
				SET(FFMPEG_LIBRARY_DIR ${FFMPEG_DIR}/hisiv500)
			endif()

			if (CMAKE_C_COMPILER MATCHES "hisiv600")
				SET(FFMPEG_LIBRARY_DIR ${FFMPEG_DIR}/hisiv600)
			endif()
			
			if (CMAKE_C_COMPILER MATCHES "himix100")
				SET(FFMPEG_LIBRARY_DIR ${FFMPEG_DIR}/himix100)
			endif()

		else(CMAKE_TOOLCHAIN_FILE)
		
			if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
				SET(FFMPEG_LIBRARY_DIR /usr/local/lib ${THIRD_PARTY}/ffmpeg/arm ${FFMPEG_DIR}/lib ${FFMPEG_DIR}/bin)
			endif()

		endif(CMAKE_TOOLCHAIN_FILE)
	endif(WIN32)
	
endif ()

message("FFMPEG_INCLUDE_DIR=${FFMPEG_INCLUDE_DIR}")
message("FFMPEG_DIR=${FFMPEG_DIR}")
message("FFMPEG_LIBRARY_DIR=${FFMPEG_LIBRARY_DIR}")
